package com.yuwj.chinaa.util;

import java.math.BigDecimal;

/**
 * Created by Administrator on 2018/1/4.
 */

public class MathUtil {

    public static double multiply(String a, String b) {
        double result = 0;
        try {
            double aDouble = Double.valueOf(a);
            double bDouble = Double.valueOf(b);


            BigDecimal aBigDecimal = new BigDecimal(aDouble);
            BigDecimal bBigDecimal = new BigDecimal(bDouble);
            result = aBigDecimal.multiply(bBigDecimal).doubleValue();
            result = (double)Math.round(result*100)/100;//转化为两位小数,并四舍五入
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return result;
    }
}
